' Written by Craig'n'Dave
Module Module1
    ' Bubble sort
    Function bubble_sort(items() As String)
        Dim n As Integer = items.Count
        Dim index As Integer
        Dim swapped As Boolean = True
        Dim temp As String
        ' Start a new pass until no swap is made
        While n > 0 And swapped = True
            swapped = False
            ' Last item has bubbled to the top and no longer needs to be checked
            n = n - 1
            ' Compare all items except those already sorted
            For index = 0 To n - 1
                If items(index) > items(index + 1) Then
                    temp = items(index)
                    items(index) = items(index + 1)
                    items(index + 1) = temp
                    swapped = True
                End If
            Next
        End While
        Return items
    End Function

    Sub Main()
        ' Main porogram starts here
        Dim items() As String = {"Florida", "Georgia", "Delaware", "Alabama", "California"}
        items = bubble_sort(items)
        Console.WriteLine(String.Join(", ", items))
    End Sub
End Module
